{
    _CP_.OPTIONS_HANDLER.set('disabled', {
        [Etype.boolean]: U.F.fn.obj,
    });
}

type Toptions_DISABLED = {
    /** 禁用状态 */
    disabled?: boolean;
};

interface KHTMLElement {
    /**
     * 设置禁用状态
     * @returns 当前元素对象
     */
    disable(): KHTMLElement;
}
{
    Object.defineProperty(KHTMLElement.prototype, 'disable', {
        writable: false,
        configurable: false,
        enumerable: false,
        value: function (this: KHTMLElement) {
            const plugin = this.getPlugin();
            if (plugin) {
                const creator = plugin.ele()!.creator;
                if ('disable' in creator!) {
                    (creator as any).disable();
                }
                plugin.addClass(_CP_.CLASSES.DISABLED);
            }
            return this;
        }
    });
}
interface KHTMLElement {
    /**
     * 设置启用状态
     * @returns 当前元素对象
     */
    enable(): KHTMLElement;
}
{
    Object.defineProperty(KHTMLElement.prototype, 'enable', {
        writable: false,
        configurable: false,
        enumerable: false,
        value: function (this: KHTMLElement) {
            const plugin = this.getPlugin();
            if (plugin) {
                const creator = plugin.ele()!.creator;
                if ('enable' in creator!) {
                    (creator as any).enable();
                }
                plugin.removeClass(_CP_.CLASSES.DISABLED);
            }
            return this;
        }
    });
}

/**
 * 禁用控件注解
 * @param target 目标类型
 */
function ACdisabled(target: any) {
    if (!U.isSubClass(_CP_, target)) { return; }

    // 处理器
    const original_options_handlers = target.prototype.options_handlers;
    target.prototype.options_handlers = function (this: _CP_<any>) {
        const options_handlers = original_options_handlers.call(this);

        U.O.setDefaultValue(options_handlers, 'disabled', _CP_.OPTIONS_HANDLER.get('disabled'));

        return options_handlers;
    };

    // 初始化
    const original_afterInitializer = target.prototype.afterInitializer;
    target.prototype.afterInitializer = function (this: _CP_<any>) {
        original_afterInitializer.call(this);

        // 禁用状态
        if (this.options.disabled) {
            this.ele.disable();
        }
    };
}
